package com.pinyoumei.app.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aliyun.utils.AppUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.FirstBean;
import com.pinyoumei.app.bean.FirstloadNewBean;
import com.pinyoumei.app.utils.ScreenUtils;

import java.util.List;

/**
 * Created by Administrator on 2021-08-09.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-09        Administrator             新增Person类
 * 2021-08-09        Administrator             增加sex属性
 */
public class BottomFirstNewAdapter extends BaseQuickAdapter<FirstloadNewBean.FirstloadNewDto, BaseViewHolder> {

    public BottomFirstNewAdapter(int layoutResId, @Nullable List<FirstloadNewBean.FirstloadNewDto> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FirstloadNewBean.FirstloadNewDto item) {

        if(helper.getPosition() == 0){
            helper.setBackgroundRes(R.id.ll_layout,R.drawable.shanpe_f5f5f5_10dp);
            helper.setImageResource(R.id.iv_bg_luk,R.mipmap.luck_draw_icon);
            helper.setVisible(R.id.iv_bg_luk, true);
            helper.setVisible(R.id.iv_bg, false);
            helper.setVisible(R.id.tv_goods_name, false);
            helper.setVisible(R.id.tv_sale_icon_layout, false);
            helper.setVisible(R.id.tv_sale_price_layout,false);
        }else {
            helper.setBackgroundRes(R.id.ll_layout,R.drawable.shanpe_white_10dp);
            ImageView iv_pt_goods_img = helper.getView(R.id.iv_bg);
            Glide.with(mContext).load(item.getGoods_img()).into(iv_pt_goods_img);
            helper.setText(R.id.ifb_tag1,item.getTag1());
            helper.setText(R.id.ifb_tag2,item.getTag2());
            helper.setText(R.id.tv_goods_name, item.getGoods_name());
            helper.setText(R.id.tv_sale_price, item.getSale_price());
            helper.setText(R.id.tv_market_price, "¥"+item.getMarket_price());
            TextView textView = helper.getView(R.id.tv_market_price);
            textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
            helper.setVisible(R.id.iv_bg_luk, false);
            helper.setVisible(R.id.iv_bg, true);
            helper.setVisible(R.id.tv_goods_name, true);
            helper.setVisible(R.id.tv_sale_icon_layout, true);
            helper.setVisible(R.id.tv_sale_price_layout,true);
            TextView tag1 = helper.getView(R.id.ifb_tag1);
            TextView tag2 = helper.getView(R.id.ifb_tag2);

            if(TextUtils.isEmpty(item.getTag1())){
                tag1.setVisibility(View.INVISIBLE);
            }else{
                tag1.setVisibility(View.VISIBLE);
            }
            if(TextUtils.isEmpty(item.getTag2())){
                tag2.setVisibility(View.INVISIBLE);
            }else{
                tag2.setVisibility(View.VISIBLE);
            }
        }
    }
}
